package com.cy.model;

import com.cy.BasicModel;
import com.cy.ext.plugin.tablebind.TableBind;

import java.util.Date;
import java.util.List;

@TableBind(tableName="region_map_ip",pkName = "ip")
public class RegionMapIp extends BasicModel<RegionMapIp> {
    public static final RegionMapIp dao = new RegionMapIp();
    public static final String SELECT_ALL = "`ip`,`province`,`city`,`district`,`last_updated_time`";

    /**
     * 查询未更新的记录
     */
    public List<RegionMapIp> findUnupdatedLimit(int fetchSize) {
        return find("SELECT * FROM region_map_ip WHERE last_updated_time IS NULL LIMIT ?", fetchSize);
    }

    @Override
    public boolean update() {
        setLastUpdatedTime(new Date());
        return super.update();
    }

    public RegionMapIp setIp(String ip){
        return this.set("ip",ip);
    }

    public String getIp(){
        return this.getStr("ip");
    }
        
    public RegionMapIp setProvince(String province){
        return this.set("province",province);
    }

    public String getProvince(){
        return this.getStr("province");
    }
        
    public RegionMapIp setCity(String city){
        return this.set("city",city);
    }

    public String getCity(){
        return this.getStr("city");
    }
        
    public RegionMapIp setDistrict(String district){
        return this.set("district",district);
    }

    public String getDistrict(){
        return this.getStr("district");
    }
        
    public RegionMapIp setLastUpdatedTime(Date lastUpdatedTime){
        return this.set("last_updated_time",lastUpdatedTime);
    }

    public Date getLastUpdatedTime(){
        return this.get("last_updated_time");
    }

}